package io.renren.modules.app.controller;


import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.app.entity.ArticleComment;
import io.renren.modules.app.service.ArticleCommentService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * 文章评论表
 *
 * @author chenjiacheng
 * @email 
 * @date 2019-02-11 19:04:20
 */
@RestController
@RequestMapping("app/articlecomment")
public class ArticleCommentController {
    @Autowired
    private ArticleCommentService articleCommentService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("app:articlecomment:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = articleCommentService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{commentId}")
    @RequiresPermissions("app:articlecomment:info")
    public R info(@PathVariable("commentId") Integer commentId){
			ArticleComment articleComment = articleCommentService.selectById(commentId);

        return R.ok().put("articleComment", articleComment);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("app:articlecomment:save")
    public R save(@RequestBody ArticleComment articleComment){
			articleCommentService.insert(articleComment);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("app:articlecomment:update")
    public R update(@RequestBody ArticleComment articleComment){
			articleCommentService.updateById(articleComment);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("app:articlecomment:delete")
    public R delete(@RequestBody Integer[] commentIds){
			articleCommentService.deleteBatchIds(Arrays.asList(commentIds));

        return R.ok();
    }

}
